home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / baswiz17.zip / QUESTION.TXT < prev    next >
Text File  |  1991-06-12  |  7KB  |  190 lines

  1.                       Common Questions about QuickBASIC
  2.  
  3.  
  4.  
  5. After spending much time on CompuServe, BIX, the FidoNet QuickBASIC echo and
  6. other national BASIC forums, I've noticed that there is a lot of repetition.
  7. People ask the same questions, time after time.  They must be good questions!
  8. Here is a compilation of a few of the more common questions.
  9.  
  10.  
  11.  
  12. Question:
  13.    How can I disable Control-Break?
  14.  
  15. Answer:
  16.    Programs compiled with QuickBASIC or BASCOM usually don't have to worry
  17.    about this.  Control-Break is disabled unless you compile with the /D
  18.    (debug) option.  In the event that you are doing something that QuickBASIC
  19.    doesn't completely control, like printing to the screen via DOS functions,
  20.    this protection no longer holds.  In that case, you may be able to disable
  21.    Break by getting DOS to check for it less frequently.  Use the command
  22.       BREAK OFF
  23.    from a batch file, or execute it from BASIC like so:
  24.       SHELL "COMMAND BREAK OFF"
  25.  
  26.  
  27.  
  28. Question:
  29.    How can I get the error level from a SHELLed program?  How can I get my
  30.    program to return an error level?
  31.  
  32. Answer:
  33.    That requires assembly language.  My PBClone library contains such
  34.    routines.  I believe the QB4BAS library also has those capabilities.
  35.  
  36.  
  37.  
  38. Question:
  39.    How can I read the command line from BASIC?
  40.  
  41. Answer:
  42.    The COMMAND$ function will do it for you.  Note that COMMAND$ doesn't
  43.    return the exact command line-- it is trimmed somewhat and capitalized.
  44.  
  45.  
  46.  
  47. Question:
  48.    How can I get access to COM3 and COM4 for my communications program?
  49.  
  50. Answer:
  51.    BASIC doesn't provide support for those comm ports.  However, there are
  52.    many add-on libraries which will let you do it.  Look for BASWIZ, QBCOM,
  53.    or QBSER, among others.
  54.  
  55. Question:
  56.    How can I get a directory listing into an array?
  57.  
  58. Answer:
  59.    Most BASIC libraries can do this for you.  Another way to do this is to
  60.    put the directory listing into a file by
  61.       SHELL "DIR *.* >DIRLIST.TXT"
  62.    and then read the file into an array.  Yet another alternative is to use
  63.    the FILES statement on a non-displayed screen page (if you have a CGA, EGA
  64.    or VGA) or in invisible colors (say, black on black), then get the results
  65.    from the screen with the SCREEN function.
  66.  
  67.  
  68.  
  69. Question:
  70.    How can I see if a file exists?
  71.  
  72. Answer:
  73.    Most BASIC libraries can do this for you.  Or, you can use the directory
  74.    approach given above.  Yet another way to do it is to try to open the file
  75.    for input:
  76.  
  77.          ON ERROR GOTO NotFound
  78.          OPEN File$ FOR INPUT AS #1
  79.          CLOSE #1
  80.          Found = -1
  81.       Done:
  82.          RETURN
  83.       NotFound:
  84.          Found = 0
  85.          RESUME Done
  86.  
  87.  
  88.  
  89. Question:
  90.    I'm running out of string space.  What can I do?
  91.  
  92. Answer:
  93.    If you have arrays, try moving them outside of the string space area.
  94.    Either use REDIM to dimension 'em or use the REM $DYNAMIC metacommand.  If
  95.    this doesn't help enough, use fixed-length strings, which are stored
  96.    outside the regular string area.  Still not enough room?  Well, you can
  97.    buy Microsoft's BASCOM 7.x "Professional Development System", which will
  98.    set you back about $300.  Or, you can simply use the "far string" routines
  99.    provided in my BASWIZ library.
  100.  
  101. Question:
  102.    I'd like to constantly display the time.  What do I do?
  103.  
  104. Answer:
  105.    That's also available in libraries, including PBClone.  You can do it
  106.    yourself using an approach like this, among other ways:
  107.  
  108.          ON TIMER(1) GOSUB DisplayTime
  109.          TIMER ON
  110.          ' your program goes here
  111.       DisplayTime:
  112.          OldRow = CSRLIN
  113.          OldCol = POS(0)
  114.          LOCATE 25, 70
  115.          PRINT TIME$;
  116.          LOCATE OldRow, OldCol
  117.          RETURN
  118.  
  119.  
  120.  
  121. Question:
  122.    I need to know how many days lie in between two dates.  How do I do it?
  123.  
  124. Answer:
  125.    As usual... this is something you can get in a library from your local
  126.    BBS.  Try QB4BAS.  It's quite possible to do it in BASIC, but I can never
  127.    remember the proper formulae... you need to account for leap years and
  128.    leap centuries, so it isn't as straightforward as you might guess.
  129.  
  130.  
  131.  
  132. Question:
  133.    How can I use ANSI display codes?
  134.  
  135. Answer:
  136.    You need to go through DOS display functions for that to work.  Use this:
  137.       OPEN "CON" FOR OUTPUT AS #1
  138.    This makes the DOS display functions available as file (device) number
  139.    one.  You can print to it using normal file statements:
  140.       PRINT #1, CHR$(27); "[2J";
  141.    The above statement will clear the screen if an ANSI driver is installed.
  142.    See your DOS manual for information on the available ANSI codes.  You can
  143.    also get this information from your friendly local BBS.
  144.  
  145.    If you are using the BASWIZ library, check out ANSIprint in the
  146.    Telecommunications section.  It handles ANSI in a virtual window and also
  147.    allows for "ANSI" music processing if desired.  ANSI.SYS not needed.
  148.  
  149. Question:
  150.    How can I print the screen to the printer, in text or graphics mode?
  151.  
  152. Answer:
  153.    One simple solution is to use CALL INTERRUPT.  Interrupt number 5 (five)
  154.    does the same thing as pressing PrintScreen/PrtSc on your keyboard.  It
  155.    will handle CGA graphics as well as text mode if GRAPHICS is installed
  156.    (GRAPHICS.COM or GRAPHICS.EXE is provided with DOS).
  157.  
  158.    If you are just using text mode, check into the SCREEN function, which
  159.    allows you to read characters off the display.  If you collect each row
  160.    into a string and then use RTRIM$ to remove trailing blanks, it'll be
  161.    faster than sending all those meaningless blanks to the printer.
  162.  
  163.    My BASWIZ library also provides a PrintScreen routine which will work on
  164.    virtually any text or graphics mode, given an Epson-compatible printer.
  165.  
  166.  
  167.  
  168. Question:
  169.    How can I display picture files, like GIF, PCX, MAC, MSP and so forth?
  170.  
  171. Answer:
  172.    Well, the BASWIZ library can help with MAC and PCX files.  Probably the
  173.    best solution for a general-purpose picture handler, though, would be to
  174.    get a copy of OPTIKS (usually distributed as OK followed by a version
  175.    number) or another picture format converter at your local BBS.  Image
  176.    translation tends to be somewhat difficult and slow in BASIC, and it's
  177.    hard to find the information needed to handle the various formats
  178.    available.  If you can read other languages than BASIC, you can find
  179.    source code for various picture handlers on your local BBS.  These are
  180.    often written in assembly language, C, and Pascal, which are better for
  181.    this specific purpose than BASIC.
  182.  
  183.  
  184.  
  185. Have I mentioned BBSes a lot?!  If you don't have a modem, make the
  186. investment!  It will be well worth it, whether you are a serious programmer
  187. or just like to fiddle around now and then.  There are vast numbers of files
  188. and helpful people within reach of a telephone call of your computer!
  189.  
  190.